Page 96 - 2629_Devagiri_C-8
P. 96

LEARNING LOGS



                  A.  Tick ( ) the correct option.

                     1.  Which of the following is the correct syntax of a for loop?
                                (i)  for (i = 0; i < 5; i++)              (ii)  for i in range(5)

                               (iii)  for i to 5                          (iv)  for i while 5

                     2.  Identify the function that is used to generate a sequence of numbers.

                                (i)  sequence()                           (ii)  generate()

                               (iii)  range()                             (iv)  list()

                     3.  Which of the following loops is used when the number of repetitions is not known in advance?
                                (i)  for loop                             (ii)  while loop

                               (iii)  break loop                          (iv)  continue loop

                     4.  Spot the output of the code:

                         for i in range(2, 7):
                             print(i + 3)

                                (i)  2, 3, 4, 5, 6                        (ii)  5, 6, 7, 8, 9

                               (iii)  3, 4, 5, 6, 7                       (iv)  7, 8, 9, 10, 11

                     5.  Which of the following is considered a jump statement in Python?
                                (i)  for                                  (ii)  while

                               (iii)  break                               (iv)  if


                  B.  Fill in the blanks using the given hints:
                     1.  The             loop repeats a block of statements a fixed number of times.
                                                                                                             Hints
                     2.  The loop variable is initialised with the        value in the range() function.      start
                                                                                                             Infinite
                     3.   The             statement is used to exit a loop before it has completed all its    For
                                                                                                             Break
                         iterations.                                                                        Iteration
                     4.              means repeating a set of instructions again and again.

                     5.  An              loop never ends because its condition is always true and never becomes false.


                  C.  Write  T  for true and  F  for false.
                     1.  A while loop is useful when the number of repetitions is known in advance.

                     2.  The range() function can be used only with three arguments.





                   94
                        Premium Edition-VIII
   91   92   93   94   95   96   97   98   99   100   101